package com.ldc.wandroid.adapter;

import android.widget.CheckBox;

import androidx.annotation.NonNull;

import com.ldc.common.common.CommonRecyclerView;
import com.ldc.common.common.CommonRecyclerViewHolder;
import com.ldc.common.utils.TimeUtils;
import com.ldc.wandroid.R;
import com.ldc.common.config.ArgParams;
import com.ldc.wandroid.model.ArticleModel;

import java.sql.Date;

public class HomeArticleAdapter extends CommonRecyclerView<ArticleModel.DatasBean> {


    public HomeArticleAdapter() {
        super(R.layout.layout_item_home_article);
    }

    @Override
    protected void convert2Data(@NonNull CommonRecyclerViewHolder holder, ArticleModel.DatasBean bean, int position) {
        holder.setText(R.id.tv_title, String.format("%s•%s", bean.getSuperChapterName(), bean.getChapterName()));
        holder.setText(R.id.tv_context, String.format("%s", bean.getTitle()));
        holder.setText(R.id.tv_author, String.format("%s", bean.getAuthor()));
        holder.setText(R.id.tv_time, String.format("%s", TimeUtils.date2String(new Date(bean.getPublishTime()), "yyyy/MM/dd")));
        //
        holder.setVisible(R.id.tv_top_tag, bean.getItemType() != ArgParams.HOME_ARTICLE_CODE);
        ((CheckBox) holder.findViewById(R.id.ck_collect)).setChecked(bean.isCollect());
    }
}
